//
//  SCHotelReserveViewController.m
//  shangcheng
//
//  Created by Jie Jie on 2019/8/1.
//  Copyright © 2019 张艳江. All rights reserved.
//

#import "SCHotelReserveViewController.h"

#define k_view_rl_space       10
#define k_view_label_h        17
#define k_bottom_view_h       50

@interface SCHotelReserveViewController ()<UITextFieldDelegate>

@property (nonatomic , strong) UITextField *hotel_room_count_tf;
@property (nonatomic , strong) UITextField *hotel_number_tf;
@property (nonatomic , strong) UITextField *tel_tf;

@property (nonatomic , strong) UIView *bottom_view;
@property (nonatomic , strong) UILabel *price_label;
@property (nonatomic , strong) UIButton *reserve_button;


@end

@implementation SCHotelReserveViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor =[UIColor whiteColor];
    [self createUI];
}

-(void)createUI{
    
    UIButton *back_button = [[UIButton alloc] initWithFrame:CGRectMake(0, kStatusBarHeight , 50, 50)];
    [back_button addTarget:self action:@selector(clickBackButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:back_button];
    
    UIImageView *back_image = [[UIImageView alloc] initWithFrame:CGRectMake(7, 9, 10, 17)];
    back_image.image = [UIImage imageNamed:@"back"];
    [back_button addSubview:back_image];
    
    UILabel *title_label = [[UILabel alloc] initWithFrame:CGRectMake(0, kStatusBarHeight, kScreenW, kNavBarHeight)];
    title_label.text = @"预定提交";
    title_label.textAlignment = NSTextAlignmentCenter;
    title_label.font = [UIFont systemFontOfSize:15];
    [self.view addSubview:title_label];
    
    UILabel *hotel_name_label = [[UILabel alloc] init];
    hotel_name_label.text = @"泉州友德大酒店";
    hotel_name_label.textAlignment = NSTextAlignmentLeft;
    hotel_name_label.font = [UIFont systemFontOfSize:16];
    hotel_name_label.textColor = [UIColor blackColor];
    [self.view addSubview:hotel_name_label];
    
    UILabel *hotel_reserve_timer_label = [[UILabel alloc] init];
    hotel_reserve_timer_label.text = @"4月28日-4月29日 共1晚";
    hotel_reserve_timer_label.textAlignment = NSTextAlignmentLeft;
    hotel_reserve_timer_label.font = [UIFont systemFontOfSize:12];
    hotel_reserve_timer_label.textColor = RGB(102, 102, 102);
    [self.view addSubview:hotel_reserve_timer_label];
    
    UILabel *hotel_room_type_label = [[UILabel alloc] init];
    hotel_room_type_label.text = @"标准双人间";
    hotel_room_type_label.textAlignment = NSTextAlignmentLeft;
    hotel_room_type_label.font = [UIFont systemFontOfSize:12];
    hotel_room_type_label.textColor = RGB(102, 102, 102);
    [self.view addSubview:hotel_room_type_label];
    
    UIView *hotel_remark_view = [[UIView alloc] init];
    hotel_remark_view.backgroundColor = RGB(255, 244, 229);
    [self.view addSubview:hotel_remark_view];
    
    UILabel *hotel_remark_label = [[UILabel alloc] init];
    hotel_remark_label.text = @"已过取消时间，预定成功后不可取消";
    hotel_remark_label.textAlignment = NSTextAlignmentLeft;
    hotel_remark_label.font = [UIFont systemFontOfSize:12];
    hotel_remark_label.textColor = RGB(231, 157, 58);
    [hotel_remark_view addSubview:hotel_remark_label];
    
    UILabel *hotel_room_count_label = [[UILabel alloc] init];
    hotel_room_count_label.text = @"房间数";
    hotel_room_count_label.textAlignment = NSTextAlignmentLeft;
    hotel_room_count_label.font = [UIFont systemFontOfSize:12];
    hotel_room_count_label.textColor = [UIColor blackColor];
    [self.view addSubview:hotel_room_count_label];
    [self.view addSubview:self.hotel_room_count_tf];
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = RGB(244, 244, 244);
    [self.view addSubview:line];
    
    UILabel *hotel_number_label = [[UILabel alloc] init];
    hotel_number_label.text = @"入住人";
    hotel_number_label.textAlignment = NSTextAlignmentLeft;
    hotel_number_label.font = [UIFont systemFontOfSize:12];
    hotel_number_label.textColor = [UIColor blackColor];
    [self.view addSubview:hotel_number_label];
    [self.view addSubview:self.hotel_number_tf];
    
    UIView *line_1 = [[UIView alloc] init];
    line_1.backgroundColor = RGB(244, 244, 244);
    [self.view addSubview:line_1];
    
    UILabel *tel_label = [[UILabel alloc] init];
    tel_label.text = @"联系手机";
    tel_label.textAlignment = NSTextAlignmentLeft;
    tel_label.font = [UIFont systemFontOfSize:12];
    tel_label.textColor = RGB(102, 102, 102);
    [self.view addSubview:tel_label];
    [self.view addSubview:self.tel_tf];
    
    UIView *line_2 = [[UIView alloc] init];
    line_2.backgroundColor = RGB(244, 244, 244);
    [self.view addSubview:line_2];
    
    UILabel *jf_label = [[UILabel alloc] init];
    jf_label.text = @"积分抵扣";
    jf_label.textAlignment = NSTextAlignmentLeft;
    jf_label.font = [UIFont systemFontOfSize:12];
    jf_label.textColor = RGB(102, 102, 102);
    [self.view addSubview:jf_label];
    
    UILabel *jf_r_label = [[UILabel alloc] init];
    jf_r_label.text = @"可抵扣5元>";
    jf_r_label.textAlignment = NSTextAlignmentRight;
    jf_r_label.font = [UIFont systemFontOfSize:12];
    jf_r_label.textColor = RGB(102, 102, 102);
    [self.view addSubview:jf_r_label];
    
    UIView *line_4 = [[UIView alloc] init];
    line_4.backgroundColor = RGB(244, 244, 244);
    [self.view addSubview:line_4];
    
    UILabel *return_label = [[UILabel alloc] init];
    return_label.text = @"退款规则";
    return_label.textAlignment = NSTextAlignmentLeft;
    return_label.font = [UIFont systemFontOfSize:12];
    return_label.textColor = RGB(102, 102, 102);
    [line_4 addSubview:return_label];
    
    UILabel *return_info_label = [[UILabel alloc] init];
    return_info_label.text = @"根据酒店政策，预定成功后不可取消/变更，如未入住，酒店将扣除全额房费。预定成功后15分钟内可免费取消，无需商家同意即可马上退款至您的支付账户。";
    return_info_label.textAlignment = NSTextAlignmentLeft;
    return_info_label.numberOfLines = 3;
    return_info_label.font = [UIFont systemFontOfSize:12];
    return_info_label.textColor = RGB(163, 163, 163);
    [line_4 addSubview:return_info_label];
    
    UIView *line_3 = [[UIView alloc] init];
    line_3.backgroundColor = RGB(244, 244, 244);
    [self.view addSubview:line_3];
    [self.view addSubview:self.bottom_view];
    
    [line_3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(kTopHeight);
        make.height.mas_equalTo(5);
        make.right.mas_equalTo(0);
    }];
    
    [hotel_name_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(line_3.mas_bottom).mas_offset(13);
        make.height.mas_equalTo(23);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [hotel_reserve_timer_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(hotel_name_label.mas_bottom).mas_offset(6);
        make.height.mas_equalTo(k_view_label_h);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [hotel_room_type_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(hotel_reserve_timer_label.mas_bottom).mas_offset(6);
        make.height.mas_equalTo(k_view_label_h);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [hotel_remark_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(hotel_room_type_label.mas_bottom).mas_offset(13);
        make.height.mas_equalTo(30);
        make.right.mas_equalTo(0);
    }];
    [hotel_remark_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(30);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    
    CGFloat label_w = 70;
    CGFloat tf_h = 40;
    [hotel_room_count_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(hotel_remark_view.mas_bottom).mas_offset(12);
        make.height.mas_equalTo(k_view_label_h);
        make.width.mas_equalTo(label_w);
    }];
    [self.hotel_room_count_tf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(hotel_room_count_label.mas_right);
        make.top.mas_equalTo(hotel_remark_view.mas_bottom);
        make.height.mas_equalTo(tf_h);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(self.hotel_room_count_tf.mas_bottom);
        make.height.mas_equalTo(1);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [hotel_number_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(line.mas_bottom).mas_offset(12);
        make.height.mas_equalTo(k_view_label_h);
        make.width.mas_equalTo(label_w);
    }];
    [self.hotel_number_tf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(hotel_number_label.mas_right);
        make.top.mas_equalTo(line.mas_bottom);
        make.height.mas_equalTo(tf_h);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [line_1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(self.hotel_number_tf.mas_bottom);
        make.height.mas_equalTo(1);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [tel_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(line_1.mas_bottom).mas_offset(12);
        make.height.mas_equalTo(k_view_label_h);
        make.width.mas_equalTo(label_w);
    }];
    [self.tel_tf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(tel_label.mas_right);
        make.top.mas_equalTo(line_1.mas_bottom);
        make.height.mas_equalTo(tf_h);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [line_2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(self.tel_tf.mas_bottom);
        make.height.mas_equalTo(5);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [jf_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(line_2.mas_bottom).mas_offset(12);
        make.height.mas_equalTo(k_view_label_h);
        make.width.mas_equalTo(label_w);
    }];
    [jf_r_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-k_view_rl_space);
        make.top.mas_equalTo(line_2.mas_bottom).mas_offset(12);
        make.height.mas_equalTo(k_view_label_h);
        make.width.mas_equalTo(label_w);
    }];
    [line_4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(jf_label.mas_bottom).mas_offset(12);
        make.bottom.mas_equalTo(self.bottom_view.mas_top);
        make.right.mas_equalTo(0);
    }];
    [return_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(19);
        make.height.mas_equalTo(19);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    [return_info_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(k_view_rl_space);
        make.top.mas_equalTo(return_label.mas_bottom).mas_offset(7);
        make.height.mas_equalTo(60);
        make.right.mas_equalTo(-k_view_rl_space);
    }];
    
}

-(UITextField *)hotel_room_count_tf{
    
    if (_hotel_room_count_tf == nil) {
        _hotel_room_count_tf = [[UITextField alloc] init];
        _hotel_room_count_tf.delegate = self;
        _hotel_room_count_tf.placeholder = @"";
        _hotel_room_count_tf.text = @"1";
        _hotel_room_count_tf.font = [UIFont systemFontOfSize:12];
        
    }
    return _hotel_room_count_tf;
}

-(UITextField *)hotel_number_tf{
    
    if (_hotel_number_tf == nil) {
        _hotel_number_tf = [[UITextField alloc] init];
        _hotel_number_tf.delegate = self;
        _hotel_number_tf.placeholder = @"多个人用逗号隔开";
        _hotel_number_tf.font = [UIFont systemFontOfSize:12];
       
    }
    return _hotel_number_tf;
}

-(UITextField *)tel_tf{
    
    if (_tel_tf == nil) {
        _tel_tf = [[UITextField alloc] init];
        _tel_tf.delegate = self;
        _tel_tf.placeholder = @"请输入手机号码";
        _tel_tf.font = [UIFont systemFontOfSize:12];
        
    }
    return _tel_tf;
}

-(UILabel *)price_label{
    
    if (_price_label == nil) {
        _price_label = [[UILabel alloc] initWithFrame:CGRectMake(k_view_rl_space, 0, (kScreenW - k_view_rl_space) * 0.65, k_bottom_view_h)];
        _price_label.text = @"¥199";
        _price_label.textColor = RGB(219, 52, 52);
        _price_label.textAlignment = NSTextAlignmentLeft;
        _price_label.font = [UIFont systemFontOfSize:18];
    }
    return _price_label;
}

-(UIButton *)reserve_button{
    
    if (_reserve_button == nil) {
        _reserve_button = [[UIButton alloc] initWithFrame:CGRectMake((kScreenW - k_view_rl_space) * 0.65 + k_view_rl_space, 0, (kScreenW - k_view_rl_space) * 0.35, k_bottom_view_h)];
        [_reserve_button setTitle:@"预定" forState:UIControlStateNormal];
        [_reserve_button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_reserve_button setBackgroundColor:RGB(231, 157, 58)];
        _reserve_button.titleLabel.font = [UIFont systemFontOfSize:15];
        
    }
    return _reserve_button;
}

-(UIView *)bottom_view{
    if (_bottom_view == nil) {
        _bottom_view = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenH - k_bottom_view_h, kScreenW, k_bottom_view_h)];
        _bottom_view.backgroundColor = [UIColor whiteColor];
        
        [_bottom_view addSubview:self.price_label];
        [_bottom_view addSubview:self.reserve_button];
    }
    return _bottom_view;
}

-(void)clickBackButton:(UIButton *)sender{
    
    [self.navigationController popViewControllerAnimated:YES];
}


@end
